home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Aug 90 / MacApp.Tech$ 8⁄24⁄90 / 1808-Overriding Beep()-Aug90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  1.3 KB  |  55 lines  |  [TEXT/GEOL]

  1. Item    6271673                         24-Aug-90        07:25PDT
  2.  
  3. From:   PHAROS.TECH                     Pharos Tech, Tech Staff,PRT
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.  
  7. Sub:    Overriding Beep()
  8.  
  9. From: Schmitz, Scott D. on Fri, Aug 24, 1990 10:25 AM
  10. Subject: Overriding Beep()
  11. To: MacApp
  12.  
  13. I just wrote some code which overrides the gApplication.Beep() procedure and
  14. gives the ability to play 'snd ' resources like hypercard.  For those who are
  15. interested here's the code:
  16.  
  17. • USES the SoundUnit.p which Apple included in their Source Code Example 24.
  18.  
  19. Put this line in the initialization code for your App.
  20.  
  21. If InitSoundUnit = 0 Then ;
  22.  
  23. Put this as the last line in your Main:
  24. FreeSoundUnit;
  25.  
  26. Override Beep like so:
  27.  
  28. {-------------------------------------------------------------}
  29. {$S MAGlobalsRes}
  30. {Duration now passes in the 'snd ' resource number}
  31.  
  32. Procedure TCalcApplication.Beep (duration: Integer);  OVERRIDE;
  33.  
  34. Var
  35.   Err : Integer;
  36.   SndHandle : handle;
  37.  
  38. Begin
  39.   FreeAllChans;
  40.   SndHandle := Handle(GetResource(soundListRsrc, duration));
  41.   Err := resError;
  42.   If Err = NoErr Then
  43.    Err := HyperSndPlay(SndHandle);
  44.  
  45.   If (Err <> NoErr) Then
  46.     Inherited Beep(duration);
  47. End;
  48.  
  49. The sound plays asynchronisly without that annoying click.
  50.  
  51. Scott
  52. Pharos Technologies
  53.  
  54.  
  55.